<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'zsls_api',
            'enableCookieValidation' => false,
            'enableCsrfValidation' => false,
		'parsers' => [//接收applicatiion/json头部
			'application/json' => 'yii\web\JsonParser',
			'text/json' => 'yii\web\JsonParser',
		 ],
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
        
        'urlManager' => [
             'enablePrettyUrl' => true, // 启用美化URL
             'enableStrictParsing' => true, // 是否执行严格的url解析
             'showScriptName' => false, // 在URL路径中是否显示脚本入口文件
            'rules' => [//url:localhost/xxx/web/v1/sites(复数)
                 [
                     'class' => 'yii\rest\UrlRule',
                     'controller' => [
                         'v1/user',
                         'v1/user-file',
                         'v1/user-info',
                         'v1/user-money',
                         'v1/user-order',
                         'v1/user-remix-info',
                         'v1/user-remix-info-all',
                         'v1/user-talk-record',
                         'v1/user-money-record',
                         'v1/lawyer',
                         'v1/lawyer-file',
                         'v1/lawyer-info',
                         'v1/lawyer-money',
                         'v1/lawyer-order',
                         'v1/lawyer-remix-info',
                         'v1/lawyer-remix-info-all',
                         'v1/lawyer-talk-record',
                         'v1/lawyer-money-record',
                         'v1/token',
                         'v1/pay',
                         'v1/notify'
                     ],
                 ],
             ],
         ],
        
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}
$config['modules']['v1'] = [//添加版本module
	'class' => 'app\modules\v1\Module',
];
return $config;
